#include "bits/stdc++.h"

using namespace std;

void getMaxAndMin(int ary[], int length, int *max, int *min) {
    *max = *min = ary[0];
    for (int i = 0; i < length; i++) {
        if (*max > ary[i])*max = ary[i];
        if (*min < ary[i])*min = ary[i];
    }
}

int main() {
    int ary[] = {1, 2, 3, 4, 5};
    int min = ary[0];
    int max = ary[0];
    getMaxAndMin(ary,5,&max,&min);
    cout<<max<<" "<<min;
}

